<?php
$this->setLayout('template'.DS.'default.phtml');
$this->startBlock('scriptBlocks');
?>
<script language="javascript" type="text/javascript">
$(function(){
	$('#template_id').change(function(){
		if($(this).val().length > 0){
			var positions = $($(this).find('option[value="' + $(this).val() + '"]').get(0)).attr('position').split(' ');
			var html = '';
			for(var i = 0; i < positions.length; i++){
				html += '<option value="' + positions[i] + '">' + positions[i] + '</option>';
			}
			$('#position').html(html);
		}else{
			$('#position').html('<option value="">--</option>');
		}
	});
});
</script>

<?php

$this->endBlock();

$this->startBlock('topbar');
echo $this->navigation->toHtml();
$this->endBlock();

$this->startBlock();
echo $this->toolbar->toHtml();
echo $this->form->toHtml();
if($this->ad_parameters){
    echo $this->loadTemplate($this->ad_parameters['config_path'],
            array('parameters'=>$this->ad_parameters['parameters']->toArray(),'ad_position'=>$this->ad_position));
}

if($this->contents_parameters){
    echo $this->loadTemplate($this->contents_parameters['config_path'],
            array('parameters'=>$this->contents_parameters['parameters']->toArray()));
}

if($this->mainsubject_parameters){
    echo $this->loadTemplate($this->mainsubject_parameters['config_path'],
            array('parameters'=>$this->mainsubject_parameters['parameters']->toArray()));
}
$this->endBlock();